home *** CD-ROM | disk | FTP | other *** search
/ Great Canadian Scientists / GCS_CD.iso / mac / PC / GCSData / atom_g.dxr / 00001_Main Scripts.ls next >
Encoding:
Text File  |  1996-09-01  |  7.8 KB  |  317 lines

  1. on startMovie
  2.   global AtomReacting, timer, Difficulty, rate
  3.   set timer to 0
  4.   GameStart(AtomReacting)
  5.   BSetup(20, 20)
  6.   if AtomReacting = 0 then
  7.     set AtomReacting to 0.10000000000000001
  8.   end if
  9.   set rate to 3
  10. end
  11.  
  12. on StartGame
  13.   global NoQuiz, timer, loop, rate, Tries, Energy, Angle
  14.   cursor(4)
  15.   set loop to 0
  16.   set Energy to "0"
  17.   set Angle to "45"
  18.   BSetup(20, 20)
  19.   BStart()
  20.   go("Game")
  21.   set Tries to 0
  22.   set the movieTime of sprite 4 to 0
  23.   set the movieRate of sprite 4 to rate
  24.   set NoQuiz to 1
  25.   set timer to 1
  26.   cursor(-1)
  27. end
  28.  
  29. on stop
  30.   global timer, NoQuiz, QuizWaiting
  31.   set timer to 0
  32.   repeat with count = 6 to 8
  33.     set the puppet of sprite count to 0
  34.   end repeat
  35.   set the visible of sprite 4 to 1
  36.   BStop()
  37.   BSuspend(29, 29)
  38.   BSuspend(20, 20)
  39.   go(2)
  40.   set NoQuiz to 0
  41.   if QuizWaiting = 1 then
  42.     PopQuiz()
  43.   end if
  44. end
  45.  
  46. on EndGame
  47.   global timer, TimeSec, Tries, BoxUp, rate
  48.   set timer to 0
  49.   put "Congratulations! The chemicals reacted! You took " & WriteTime(4, rate) & " and " & Tries & " tries.  Your score is " & score() & "." into field "MsgBox"
  50. end
  51.  
  52. on TimeUp
  53.   global timer, TimeSec, BoxUp
  54.   set timer to 0
  55.   set the movieRate of sprite 4 to 0
  56.   set TimeSec to 360
  57.   puppetSound("Game Over")
  58.   put "Time Up!  Because you didn't get the chemicals to react, your score is 0." into field "MsgBox"
  59.   set BoxUp to 1
  60.   go("BoxUp")
  61. end
  62.  
  63. on score
  64.   global Difficulty, Tries, rate, AtomReacting
  65.   set GameScore to 10000 - (Tries * 1000) - (Difficulty / 2 * (time(4, rate) * 10))
  66.   if GameScore < 0 then
  67.     set GameScore to 0
  68.   end if
  69.   if GameScore > AtomReacting then
  70.     set AtomReacting to GameScore
  71.   end if
  72.   ScoreDisplay()
  73.   return GameScore
  74. end
  75.  
  76. on BoxUp
  77.   if (the clickOn >= 27) and (the clickOn <= 29) then
  78.     pass()
  79.   else
  80.     if the mouseDown = 1 then
  81.       beep()
  82.     end if
  83.     dontPassEvent()
  84.   end if
  85. end
  86.  
  87. on KeyCheck
  88.   if the key = RETURN then
  89.     if (the frame >= 13) and (the frame <= 14) then
  90.       OKButton()
  91.     else
  92.       stop()
  93.     end if
  94.   else
  95.     pass()
  96.   end if
  97. end
  98.  
  99. on OKButton
  100.   global result
  101.   BSuspend(29, 29)
  102.   if value(result) = 1 then
  103.     stop()
  104.     exit
  105.   end if
  106.   EndTest()
  107. end
  108.  
  109. on ScientistScreen
  110.   cursor(4)
  111.   go(1, the pathName & "POLANY_S.DIR")
  112.   cursor(4)
  113. end
  114.  
  115. on idle
  116.   global timer, ButtonsActive
  117.   if (timer <> 0) and (the frame > 6) and (the frame < 10) then
  118.     if (the movieRate of sprite 4 = 0) or (the movieTime of sprite 4 = 21600) then
  119.       TimeUp()
  120.     end if
  121.   end if
  122.   if (the frame > 6) and (the frame < 10) then
  123.     if ButtonsActive = 1 then
  124.       CheckHilite(20, 20)
  125.     end if
  126.   end if
  127.   PopIdle()
  128.   GameIdle()
  129. end
  130.  
  131. on Test
  132.   global ReadData, DataFile, A1X, A1Y, A2X, A2Y, A3X, A3Y, result, ContactPt, EndPt, loop, CentreX, CentreY, point, Tries, Energy, Angle, Sep
  133.   cursor(4)
  134.   set Tries to Tries + 1
  135.   set the puppet of sprite 6 to 1
  136.   set the puppet of sprite 7 to 1
  137.   set the puppet of sprite 8 to 1
  138.   set DataFile to Energy & "-" & Angle
  139.   put DataFile
  140.   set A1X to EMPTY
  141.   set A1Y to EMPTY
  142.   set A2X to EMPTY
  143.   set A2Y to EMPTY
  144.   set A3X to EMPTY
  145.   set A3Y to EMPTY
  146.   set result to line 6 of the text of cast DataFile
  147.   if value(result) = 0 then
  148.     put "No reaction.  Please try again." into field "MsgBox"
  149.   end if
  150.   if value(result) = 1 then
  151.     put "Congratulations! The chemicals reacted!" into field "MsgBox"
  152.   end if
  153.   if value(result) = 2 then
  154.     put "No reaction, only hydrogen atoms were exchanged.  Please try again." into field "MsgBox"
  155.   end if
  156.   set ContactPt to line 7 of the text of cast DataFile
  157.   repeat with Counter = 1 to 150
  158.     set Temp to line Counter + 7 of the text of cast DataFile
  159.     put word 1 of Temp into line Counter of A1X
  160.     put word 2 of Temp into line Counter of A1Y
  161.     put word 3 of Temp into line Counter of A2X
  162.     put word 4 of Temp into line Counter of A2Y
  163.     put word 5 of Temp into line Counter of A3X
  164.     put word 6 of Temp into line Counter of A3Y
  165.   end repeat
  166.   set EndPt to 0
  167.   repeat with Counter = 1 to 150
  168.     if (line Counter of A1X = EMPTY) and (EndPt = 0) then
  169.       set EndPt to Counter - 1
  170.     end if
  171.   end repeat
  172.   set CentreX to 640 / 2
  173.   set CentreY to 480 / 2
  174.   set loop to 0
  175.   puppetTempo(8 * (value(Energy) + 1))
  176.   go("React")
  177. end
  178.  
  179. on EndTest
  180.   global result, ButtonsActive
  181.   set ButtonsActive to 1
  182.   go("Game2")
  183. end
  184.  
  185. on AfterTest
  186.   global Tries, result
  187.   if value(result) = 1 then
  188.     EndGame()
  189.   end if
  190.   set the locH of sprite 6 to -100
  191.   set the locH of sprite 7 to -100
  192.   set the locH of sprite 8 to -100
  193.   go("AfterReact")
  194.   if value(result) = 1 then
  195.     puppetSound("Win")
  196.   end if
  197. end
  198.  
  199. on Lock
  200.   global Energy, Angle, X, Y, z
  201.   if the locH of sprite 12 < 171 then
  202.     set the locH of sprite 12 to 140
  203.     set Energy to "0"
  204.   end if
  205.   if (the locH of sprite 12 > 170) and (the locH of sprite 12 < 232) then
  206.     set the locH of sprite 12 to 201
  207.     set Energy to "1"
  208.   end if
  209.   if (the locH of sprite 12 > 231) and (the locH of sprite 12 < 293) then
  210.     set the locH of sprite 12 to 262
  211.     set Energy to "2"
  212.   end if
  213.   if (the locH of sprite 12 > 292) and (the locH of sprite 12 < 354) then
  214.     set the locH of sprite 12 to 323
  215.     set Energy to "3"
  216.   end if
  217.   if (the locH of sprite 12 > 353) and (the locH of sprite 12 < 415) then
  218.     set the locH of sprite 12 to 384
  219.     set Energy to "4"
  220.   end if
  221.   if (the locH of sprite 12 > 414) and (the locH of sprite 12 < 476) then
  222.     set the locH of sprite 12 to 445
  223.     set Energy to "5"
  224.   end if
  225.   if the locH of sprite 12 > 475 then
  226.     set the locH of sprite 12 to 506
  227.     set Energy to "6"
  228.   end if
  229.   if the locH of sprite 13 < 159 then
  230.     set the locH of sprite 13 to 138
  231.     set Angle to "00"
  232.   end if
  233.   if (the locH of sprite 13 > 158) and (the locH of sprite 13 < 201) then
  234.     set the locH of sprite 13 to 179
  235.     set Angle to "05"
  236.   end if
  237.   if (the locH of sprite 13 > 200) and (the locH of sprite 13 < 242) then
  238.     set the locH of sprite 13 to 220
  239.     set Angle to "10"
  240.   end if
  241.   if (the locH of sprite 13 > 241) and (the locH of sprite 13 < 283) then
  242.     set the locH of sprite 13 to 261
  243.     set Angle to "15"
  244.   end if
  245.   if (the locH of sprite 13 > 282) and (the locH of sprite 13 < 324) then
  246.     set the locH of sprite 13 to 302
  247.     set Angle to "20"
  248.   end if
  249.   if (the locH of sprite 13 > 323) and (the locH of sprite 13 < 365) then
  250.     set the locH of sprite 13 to 343
  251.     set Angle to "25"
  252.   end if
  253.   if (the locH of sprite 13 > 364) and (the locH of sprite 13 < 406) then
  254.     set the locH of sprite 13 to 384
  255.     set Angle to "30"
  256.   end if
  257.   if (the locH of sprite 13 > 405) and (the locH of sprite 13 < 447) then
  258.     set the locH of sprite 13 to 425
  259.     set Angle to "35"
  260.   end if
  261.   if (the locH of sprite 13 > 446) and (the locH of sprite 13 < 488) then
  262.     set the locH of sprite 13 to 466
  263.     set Angle to "40"
  264.   end if
  265.   if the locH of sprite 13 > 487 then
  266.     set the locH of sprite 13 to 507
  267.     set Angle to "45"
  268.   end if
  269. end
  270.  
  271. on HideInfoComplete
  272.   global timer, rate
  273.   if (the frame > 6) and (the frame < 17) then
  274.     set the movieRate of sprite 4 to rate
  275.     set timer to 1
  276.   end if
  277. end
  278.  
  279. on ShowInfoPrep
  280.   global timer
  281.   if the frame > 6 then
  282.     set timer to 0
  283.     set the movieRate of sprite 4 to 0
  284.   end if
  285.   return 1
  286. end
  287.  
  288. on SetupData
  289.   if the machineType = 256 then
  290.     set Sep to "/"
  291.   else
  292.     set Sep to ":"
  293.   end if
  294.   set castCount to 1
  295.   repeat with Energy = 0 to 6
  296.     repeat with AngleCount = 0 to 9
  297.       set Angle to AngleCount * 5
  298.       if Angle = 0 then
  299.         set Angle to "00"
  300.       end if
  301.       if Angle = 5 then
  302.         set Angle to "05"
  303.       end if
  304.       set name to Energy & "-" & Angle
  305.       set fileName to the pathName & "ATOMDATA" & Sep & name & ".DAT"
  306.       set ReadData to FileIO(mnew, "read", fileName)
  307.       put name
  308.       repeat with count = 1 to 150
  309.         put ReadData(mReadLine) into line count of field castCount of castLib 3
  310.       end repeat
  311.       set the name of member castCount of castLib 3 to name
  312.       set castCount to castCount + 1
  313.       ReadData(mdispose)
  314.     end repeat
  315.   end repeat
  316. end
  317.